package com.example.wto.myapplication;

import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import org.w3c.dom.Text;

import java.util.List;
import java.util.zip.Inflater;

/**
 * Created by wto on 4/16/2017.
 */

public class TermAdapter extends ArrayAdapter<TermBean>
{
    private Context context;
    private int resource;
    private List<TermBean> termBeanList;
    public TermAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<TermBean>
            objects)
    {
        super(context, resource, objects);
        this.context=context;
        this.resource=resource;
        this.termBeanList=objects;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        TermBean termBean=termBeanList.get(position);
        if(convertView==null)
        {
            convertView= LayoutInflater.from(context).inflate(resource,parent,false);
        }
        TextView term=(TextView)convertView.findViewById(R.id.term_textview);
        term.setText(termBean.getTermName());
        return convertView;
    }
}
